package com.pxxy.mapper;

import com.pxxy.entity.Student;
import com.pxxy.util.SqlSessionUtil;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.*;

public class StudentMapperTest2 {

    SqlSession sqlSession;
    StudentMapper studentMapper;

    @Before
    public void setUp() throws Exception {
        this.sqlSession = SqlSessionUtil.getSession();
        //动态生成Mapper接口的实现类
        this.studentMapper = this.sqlSession.getMapper(StudentMapper.class);
        //
        System.out.println(this.studentMapper);
    }

    @Test
    public void findAll() {
        final List<Student> all = this.studentMapper.findAll();
        all.forEach(System.out::println);
    }

    @Test
    public void findById() {
    }

    @Test
    public void save() {
    }

    @Test
    public void update() {
    }

    @Test
    public void delete() {
        //
        this.studentMapper.delete(112);
        //
        this.sqlSession.commit();
    }
}